function TaoMoiTin()
{
    cmd_New_tinban();  
}

function TaoMoiDaiLy()
{
    cmd_New_daily();  
}






function getListTinh_DaiLy()
{
    var cboQuocGiaID= document.getElementById("cboQuocGiaID");
    cmdGetListTinh([{name: 'QuocGiaID', value: '' + cboQuocGiaID.value + ''}]);  
}


function Save_DaiLy_Click()
{
    
    var cboQuocGiaID= document.getElementById("cboQuocGiaID").value;
 
    
    var cboTinhID= document.getElementById("cboTinhID").value;
    var txtTenDaiLy= document.getElementById("txtTenDaiLy").value;
      
    var txtDiaChi= document.getElementById("txtDiaChi").value;
    var txtDienThoai= document.getElementById("txtDienThoai").value;
    var txtEmail= document.getElementById("txtEmail").value;
    
    
    var txtURL= "";//document.getElementById("txtURL");
    var txtGioiThieu= "";//document.getElementById("txtGioiThieu");
     var txtFax= "";//document.getElementById("txtFax");
      var txtCachTrungTamTP= "0";//document.getElementById("txtCachTrungTamTP");
    
    

    Save_DaiLy([{name: 'QuocGiaID', value: '' + cboQuocGiaID + ''}
            ,{name: 'TenDaiLy', value: '' + txtTenDaiLy + ''}
            ,{name: 'TinhID', value: '' + cboTinhID + ''}
            ,{name: 'DiaChi', value: '' + txtDiaChi + ''}
            ,{name: 'DienThoai', value: '' + txtDienThoai + ''}
            ,{name: 'Email', value: '' + txtEmail + ''}
            ,{name: 'Url', value: '' + txtURL + ''}
            ,{name: 'Fax', value: '' + txtFax + ''}
            ,{name: 'CachTrungTamTP', value: '' + txtCachTrungTamTP + ''}
            ,{name: 'GioiThieu', value: '' + txtGioiThieu + ''}
        ]);
      
        
}

function Delete_daily_Click(dailyid,msg)
{
    var x=confirm(msg);
    if(x==true)
        {
        cmd_Delete_daily([{name: 'ID', value: '' + dailyid + ''}]);
        }
}
function Update_daily_Click(dailyid)
{
    cmd_Update_daily([{name: 'ID', value: '' + dailyid + ''}]);
}



function getListTinh()
{
    var cboKhuVucDang_QuocGia= document.getElementById("cboKhuVucDang_QuocGia");
    cmdGetListTinh([{name: 'QuocGiaID', value: '' + cboKhuVucDang_QuocGia.value + ''}]);  
}


 $(document).ready(function() {
    $(function(){
	    $('select[value]').each(function(){
               // alert(this.getAttribute("value"));
               if(this.getAttribute("value")!==null && this.getAttribute("value").trim()!=="" && this.getAttribute("value").trim()!=="0")
                    $(this).val(this.getAttribute("value"));
	    });
	});
 });

function getListDoiXe()
{
    var cboHangXeID= document.getElementById("cboHangXeID");
    cmdGetListDoiXe([{name: 'HangXeID', value: '' + cboHangXeID.value + ''}]);  
}

var Update_tinban_Click=function(idbantin)
{
  cmd_Update_tinban([{name: 'BangTinID', value: '' + idbantin + ''}]);  
};
var Delete_tinban_Click=function(idbantin)
{
  cmd_Delete_tinban([{name: 'BangTinID', value: '' + idbantin + ''}]);  
};
var btnSave_DangTin_Click=function()
{
    var arrThietBi = new Array();
    $("input:checkbox[name='checkIds']:checked").each(
            function () {
                arrThietBi.push(this.getAttribute("id"));
            });
    
    var HangXeID= document.getElementById("cboHangXeID").value;
     
    var Cao_KichThuoc= document.getElementById("txtCao_KichThuoc").value;
    var ChieuDaiCoSo= document.getElementById("txtChieuDaiCoSo").value;
    var ChieuRongCoSo= document.getElementById("txtChieuRongCoSo").value;
    var Dai_KichThuoc= document.getElementById("txtDai_KichThuoc").value;
   
  
    var DoiXeID= document.getElementById("cboDoiXeID").value;
     
    var DongCo= document.getElementById("txtDongCo").value;
   
    var DongXeID= document.getElementById("cboDongXeID").value;
     
    var DungTichBinhChuaNhienLieu= document.getElementById("txtDungTichBinhChuaNhienLieu").value;
   
    
    var DungTichXiLanh= document.getElementById("txtDungTichXiLanh").value;
     
    var Gia= document.getElementById("txtGia").value;
    
    var GiamSoc= document.getElementById("txtGiamSoc").value;
   
     
    
    var HeThongNapNhienLieu= document.getElementById("txtHeThongNapNhienLieu").value;
    
    var HopSo= document.getElementById("cboHopSo").value;
    var KhuVucDang_Tinh= document.getElementById("cboKhuVucDang_Tinh").value;
    var KhuVucDang_QuocGia= document.getElementById("cboKhuVucDang_QuocGia").value;
    var KieuDanDong= document.getElementById("cboKieuDanDong").value;
    var KieuDongCo= document.getElementById("txtKieuDongCo").value;
    var LoaiGia= document.getElementById("cboLoaiGia").value;
   
    var LopXe= document.getElementById("txtLopXe").value;
    var MauKhiXuatXuong= document.getElementById("txtMauKhiXuatXuong").value;
    var MauNoiThatID= document.getElementById("cboMauNoiThatID").value;
    
     
    var MauXeID= document.getElementById("cboMauXeID").value;
    var MoTat= document.getElementById("txtMoTat").value;
    //var MoTat= document.getElementsByName("txtMoTat").value;
    //alert(MoTat);
    
    var MucTieuThuNhienLieu= document.getElementById("txtMucTieuThuNhienLieu").value;
   
       
    var NamSanXuat= document.getElementById("cboNamSanXuat").value;
    //var NguoiDang= document.getElementById("txtChieuDaiCoSo").value;
    var NoiThat= document.getElementById("txtNoiThat").value;
    var PhanHangDoiXe= document.getElementById("txtPhanHangDoiXe").value;
    var Phanh= document.getElementById("txtPhanh").value;
    var QuyTrinhVanChuyen= "";//document.getElementById("txtQuyTrinhVanChuyen").value;
    var SoChoNgoi= document.getElementById("txtSoChoNgoi").value;
    var SoCua= document.getElementById("txtSoCua").value;
    var SoDaDiKM= document.getElementById("txtSoDaDiKM").value;
    var SoNguoiDaSoHuu= 0;//document.getElementById("txtSoNguoiDaSoHuu").value;
    var ThongSoKyThuatKhac= "";//document.getElementById("txtThongSoKyThuatKhac").value;
    var TienTeID= document.getElementById("cboTienTeID").value;
    var TieuDe= "";//document.getElementById("txtTieuDe").value;
    var TinhTrangXe= document.getElementById("cboTinhTrangXe").value;
    var TrongLuong= document.getElementById("txtTrongLuong").value;
    var TrongLuongKhongTai= document.getElementById("txtTrongLuongKhongTai").value;
    var VanhMam= document.getElementById("txtVanhMam").value;
    var XuatXuID= document.getElementById("cboXuatXuID").value;
    var LienHe_Ho= document.getElementById("txtLienHe_Ho").value;
    var LienHe_Ten= document.getElementById("txtLienHe_Ten").value;
    var LienHe_Email= document.getElementById("txtLienHe_Email").value;
    var LienHe_DienThoai= document.getElementById("txtLienHe_DienThoai").value;
 
    cmdsave(
            [
                {name: 'TinhTrangXe', value: '' + TinhTrangXe + ''},
                {name: 'TrongLuong', value: '' + TrongLuong + ''},
                {name: 'TrongLuongKhongTai', value: '' + TrongLuongKhongTai + ''},
                {name: 'VanhMam', value: '' + VanhMam + ''},
                {name: 'XuatXuID', value: '' + XuatXuID + ''},
                {name: 'HangXeID', value: '' + HangXeID + ''},
                {name: 'Cao_KichThuoc', value: '' + Cao_KichThuoc + ''},
                {name: 'ChieuDaiCoSo', value: '' + ChieuDaiCoSo + ''},
                {name: 'ChieuRongCoSo', value: '' + ChieuRongCoSo + ''},
                {name: 'Dai_KichThuoc', value: '' + Dai_KichThuoc + ''},
                {name: 'DoiXeID', value: '' + (DoiXeID.trim()===""?0:DoiXeID) + ''},
                {name: 'DongCo', value: '' + DongCo + ''},
                {name: 'DongXeID', value: '' + DongXeID + ''},
                {name: 'DungTichBinhChuaNhienLieu', value: '' + DungTichBinhChuaNhienLieu + ''},
                {name: 'DungTichXiLanh', value: '' + DungTichXiLanh + ''},
                {name: 'Gia', value: '' + Gia + ''},
                {name: 'GiamSoc', value: '' + GiamSoc + ''},
                {name: 'HeThongNapNhienLieu', value: '' + HeThongNapNhienLieu + ''},
                {name: 'HopSo', value: '' + HopSo + ''},
                {name: 'KhuVucDang_Tinh', value: '' + KhuVucDang_Tinh + ''},
                {name: 'KhuVucDang_QuocGia', value: '' + KhuVucDang_QuocGia + ''},
                {name: 'KieuDanDong', value: '' + KieuDanDong + ''},
                {name: 'KieuDongCo', value: '' + KieuDongCo + ''},
                {name: 'LoaiGia', value: '' + LoaiGia + ''},
                {name: 'LopXe', value: '' + LopXe + ''},
                {name: 'MauKhiXuatXuong', value: '' + MauKhiXuatXuong + ''},
                {name: 'MauNoiThatID', value: '' + MauNoiThatID + ''},
                {name: 'MauXeID', value: '' + MauXeID + ''},
                {name: 'MoTat', value: '' + MoTat + ''},
                {name: 'MucTieuThuNhienLieu', value: '' + MucTieuThuNhienLieu + ''},
                {name: 'NamSanXuat', value: '' + NamSanXuat + ''},
                {name: 'NoiThat', value: '' + NoiThat + ''},
                {name: 'PhanHangDoiXe', value: '' + PhanHangDoiXe + ''},
                {name: 'Phanh', value: '' + Phanh + ''},
                {name: 'QuyTrinhVanChuyen', value: '' + QuyTrinhVanChuyen + ''},
                {name: 'SoChoNgoi', value: '' + SoChoNgoi + ''},
                {name: 'SoCua', value: '' + SoCua + ''},
                {name: 'SoDaDiKM', value: '' + SoDaDiKM + ''},
                {name: 'SoNguoiDaSoHuu', value: '' + SoNguoiDaSoHuu + ''},
                {name: 'ThongSoKyThuatKhac', value: '' + ThongSoKyThuatKhac + ''},
                {name: 'TienTeID', value: '' + TienTeID + ''},
                {name: 'TieuDe', value: '' + TieuDe + ''},
                {name: 'LienHe_DienThoai', value: '' + LienHe_DienThoai + ''},
                {name: 'LienHe_Email', value: '' + LienHe_Email + ''},
                {name: 'LienHe_Ten', value: '' + LienHe_Ten + ''},
                {name: 'LienHe_Ho', value: '' + LienHe_Ho + ''},
                {name: 'ThietBi', value: '' + arrThietBi + ''}
            ]
        );
};




var onclickUploadfile=function(key){
    
    cmdSetParamUploadFile([{name: 'HinhAnhID', value: '' + key + ''}]);  
    $('.custom-input-group .ui-fileupload-choose input').click();
};


